export const clipboard = {
  bind(el, binding, vnode) {
    el.addEventListener('click', () => {
      if (navigator.clipboard) {
        navigator.clipboard.writeText(binding.value);
      } else {
        const textarea = document.createElement('textarea');
        textarea.value = binding.value;
        document.body.appendChild(textarea);
        textarea.select();
        document.execCommand('Copy');
        document.body.removeChild(textarea);
      }
      vnode.context.$message && vnode.context.$message.success('复制成功！');
    });
  }
};
